﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
public partial class Slider : System.Web.UI.Page
{
    Datautility DU = new Datautility();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        { 
            Getdata();
            SetValue();
            GetDummy();
        }
    }
    protected void GetDummy()
    {
        string Data = "select TStatus from TestFileUpload";
        DataTable DT = DU.getdata(Data);
        if (DT.Rows.Count > 0)
        {
            grddummy.DataSource = DT;
            grddummy.DataBind();
        }
    }
    protected void Getdata()
    {
        string Data = "select salary from TestFileUpload";
        DataTable DT = DU.getdata(Data);
        if (DT.Rows.Count > 0)
        {
            grdview.DataSource = DT;
            grdview.DataBind();            
        }
    }
    protected void SetValue()
    {
        string data_min_Max = "select MIN(salary)as MinSalary,MAX(salary)as MaxSalary from TestFileUpload";
        DataTable Dtrange = DU.getdata(data_min_Max);
        if (Dtrange.Rows.Count > 0)
        {
            txtMaxamount.Text =Convert.ToInt32(Dtrange.Rows[0]["MaxSalary"]).ToString();
            txtMinamount.Text =Convert.ToInt32(Dtrange.Rows[0]["MinSalary"]).ToString();
        }
    }
    protected void txtMinamount_TextChanged(object sender, EventArgs e)
    {
        string minamount = "select salary from TestFileUpload where salary between '"+txtMinamount.Text+"' and '"+txtMaxamount.Text+"'";
        DataTable dtminamount = DU.getdata(minamount);
        if (dtminamount.Rows.Count > 0)
        {
            grdview.DataSource = dtminamount;
            grdview.DataBind();
        }
        SetValue();
    }
    protected void txtMaxamount_TextChanged(object sender, EventArgs e)
    {
        string Maxamount = "select salary from TestFileUpload where salary between '" + txtMinamount.Text + "' and '" + txtMaxamount.Text + "'";
        DataTable dtmaxamount = DU.getdata(Maxamount);
        if (dtmaxamount.Rows.Count > 0)
        {
            grdview.DataSource = dtmaxamount;
            grdview.DataBind();
        }
        SetValue();
    }
}